using System;
using System.Web.UI;

namespace Sedna.Core.Controller.Configurations
{
    /// <summary>
    /// Summary description for StringCutDataGridColumnDataTranslator.
    /// </summary>
    public class StringCutDataTranslator : IDataTranslator
    {
        private int length = 50;

        public int Length
        {
            get { return length; }
            set { length = value; }
        }

        public object Translate(Control control, object value)
        {
            return Translate(control, value, null);
        }

        public object Translate(Control control, object value, Type targetType)
        {
            string result = String.Format("{0}",value); 
            if (result.Length > length)
                result = result.Remove(length-1);
            return result;
        }
    }
}
